#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
int f[33], t[10], x,n,cnt;
int main()
{
	cin >> n;
	for (int i = 1; i <= 7; i++)
	{
		cin >> x;
		f[x] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		cnt = 0;
		for (int j = 1; j <= 7; j++)
		{
			cin >> x;
			if (f[x] == 1)
				cnt++;
		}
		t[cnt]++;
	}
	for (int i = 7; i >= 1; i--)
		cout << t[i] << " ";
	cout << endl;
	return 0;
}